package com.rainng.coursesystem.controller.teacher;

import com.rainng.coursesystem.config.themis.annotation.Teacher;
import com.rainng.coursesystem.controller.BaseController;
import com.rainng.coursesystem.model.bo.CourseFormDTO;
import com.rainng.coursesystem.model.vo.response.ResultVO;
import com.rainng.coursesystem.service.teacher.CourseService;
import io.swagger.models.auth.In;
import org.springframework.web.bind.annotation.*;

@Teacher
@RequestMapping("/teacher/course")
@RestController("teacher_courseController")
public class CourseController extends BaseController {
    private final CourseService service;

    public CourseController(CourseService service) {
        this.service = service;
    }

    @RequestMapping("/list")
    public ResultVO list(Integer keyword,Integer grade) {
        return service.list(keyword,grade);
    }


    @PostMapping
    public ResultVO addCourse(@RequestBody CourseFormDTO dto){
        return service.addCourse(dto);
    }

    @PutMapping("/update")
    public ResultVO updateCourse(@RequestBody CourseFormDTO dto){
        return service.updateCourse(dto);
    }

    @DeleteMapping("/{id}")
    public ResultVO deleteCourse(@PathVariable Integer id){
        return service.deleteCourse(id);
    }

    @GetMapping("/{courseId}/students")
    public ResultVO getStudentOfCourse(@PathVariable Integer courseId){
        return service.getStudentOfCourse(courseId);
    }

}
